package com.sdyd.antivirus.service.impl;

import com.sdyd.antivirus.dao.GroupInfoMapper;
import com.sdyd.antivirus.model.GroupInfo;
import com.sdyd.antivirus.service.GroupInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service(value = "groupInfoService")
public class GroupInfoServiceImpl implements GroupInfoService {

    private Logger logger= LoggerFactory.getLogger(GroupInfoServiceImpl.class);

    @Autowired
    private GroupInfoMapper groupInfoMapper;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
    //尽量不要使用一个启用事务的方法，调用同一个service中另外一个启动事务的方法，可能会产生自调用问题，引起事务失效
    //在事务方法中如果使用try catch，需要手动抛出RuntimeException让spring捕捉这个异常才可以事务有效
    public GroupInfo get(String id) throws Exception {
        // TODO Auto-generated method stub
        return groupInfoMapper.selectByPrimaryKey(id);
    }

}
